/**
 * Copyright (c) 2006 RiseSoft Co.,Ltd  
 * $Header$
 */
package cn.newtest.bi.collection.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * 数据库列的定义
 *
 * @author <a href="mailto: chenjian@risesoft.net">陈健</a>
 * @version $Revision$
 * 
 */
public class DbColumn implements Comparable, Serializable {
	
	/**
	 * 列名
	 */
	private String column_name;
	private String column_name_old;
	
	/**
	 * 字段类型
	 */
	private int data_type;
	private String type_name;
	
	/**
	 * 字段长度
	 */
	private Integer data_length;
	
	/**
	 * 字段精度
	 */
	private Integer data_precision;
	
	/**
	 * 小数位数
	 */
	private Integer data_scale;
	
	/**
	 * 所属表名
	 */
	private String table_name;
	
	/**
	 * 是否主键
	 */
	private Boolean primaryKey;
	
	/**
	 * 能否为空
	 */
	private Boolean nullable;
	
	/**
	 * 字段备注，用来中文化
	 */
	private String comment;

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Boolean getNullable() {
		return nullable;
	}

	public void setNullable(Boolean nullable) {
		this.nullable = nullable;
	}

	public String getColumn_name_old() {
		return column_name_old;
	}

	public void setColumn_name_old(String column_name_old) {
		this.column_name_old = column_name_old;
	}

	public String getColumn_name() {
		return column_name;
	}

	public void setColumn_name(String column_name) {
		this.column_name = column_name;
	}

	public Integer getData_length() {
		return data_length;
	}

	public void setData_length(Integer data_length) {
		this.data_length = data_length;
	}

	public Integer getData_precision() {
		return data_precision;
	}

	public void setData_precision(Integer data_precision) {
		this.data_precision = data_precision;
	}

	public int getData_type() {
		return data_type;
	}

	public void setData_type(int data_type) {
		this.data_type = data_type;
	}

	public Boolean getPrimaryKey() {
		return primaryKey;
	}

	public void setPrimaryKey(Boolean primaryKey) {
		this.primaryKey = primaryKey;
	}

	public String getTable_name() {
		return table_name;
	}

	public void setTable_name(String table_name) {
		this.table_name = table_name;
	}

	public Integer getData_scale() {
		return data_scale;
	}

	public void setData_scale(Integer data_scale) {
		this.data_scale = data_scale;
	}

	/**
	 * @see java.lang.Comparable#compareTo(Object)
	 */
	public int compareTo(Object object) {
		DbColumn myClass = (DbColumn) object;
		return new CompareToBuilder().append(this.data_precision, myClass.data_precision).append(this.data_type, myClass.data_type).append(this.primaryKey, myClass.primaryKey).append(this.table_name, myClass.table_name).append(this.data_length, myClass.data_length).append(this.nullable,
				myClass.nullable).append(this.data_scale, myClass.data_scale).append(this.comment, myClass.comment).append(this.column_name, myClass.column_name).toComparison();
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof DbColumn)) {
			return false;
		}
		DbColumn rhs = (DbColumn) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(this.data_precision, rhs.data_precision).append(this.data_type, rhs.data_type).append(this.primaryKey, rhs.primaryKey).append(this.table_name, rhs.table_name).append(this.data_length, rhs.data_length).append(this.nullable,
				rhs.nullable).append(this.data_scale, rhs.data_scale).append(this.comment, rhs.comment).append(this.column_name, rhs.column_name).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(1880035725, 2116227865).appendSuper(super.hashCode()).append(this.data_precision).append(this.data_type).append(this.primaryKey).append(this.table_name).append(this.data_length).append(this.nullable).append(this.data_scale).append(this.comment).append(
				this.column_name).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("data_type", this.data_type).append("nullable", this.nullable).append("table_name", this.table_name).append("column_name", this.column_name).append("data_scale", this.data_scale).append("primaryKey", this.primaryKey).append("data_precision",
				this.data_precision).append("data_length", this.data_length).append("comment", this.comment).toString();
	}

	public String getType_name() {
		return type_name;
	}

	public void setType_name(String type_name) {
		this.type_name = type_name;
	}

}
